package com.qyzmt.controller;

import com.qyzmt.pojo.*;
import com.qyzmt.service.CalculatorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequestMapping("/api/calculator")
@RestController
public class CalculatorController {

    @Autowired
    private CalculatorService calculatorService;

    @PostMapping("shopping")
    public Result shopping(@RequestBody Shopping shopping){
        log.info("用户访问:智能计算-消费购物维权计算器,传入参数:{}",shopping);
        // 调用Service层
        ShoppingResult shoppingResult = calculatorService.shopping(shopping);

        // 响应结果部分
        return Result.success(shoppingResult);
    }

    @PostMapping("/labor")
    public Result labor(@RequestBody Labor labor){
        log.info("用户访问:智能计算-兼职劳务维权计算器,传入参数:{}",labor);
        LaborResult laborResult = calculatorService.labor(labor);
        return Result.success(laborResult);
    }

    @PostMapping("/rental")
    public Result rental(@RequestBody Rental rental){
        log.info("用户访问:智能计算-租房住宿维权计算器,传入参数:{}",rental);
        RentalResult rentalResult = calculatorService.rental(rental);
        return Result.success(rentalResult);

    }

    @PostMapping("studyAbroad")
    public Result studyAbroad(@RequestBody StudyAbroad studyAbroad){
        log.info("用户访问:智能计算-出国留学维权计算器,传入参数:{}",studyAbroad);
        StudyAbroadResult studyAbroadResult = calculatorService.studyAbroad(studyAbroad);
        return Result.success(studyAbroadResult);
    }


}
